package variabilitysmelldetection.measurement.measures.spl;

import java.util.List;

import variabilitysmelldetection.measurement.measures.Measure;
import variabilitysmelldetection.measurement.models.ComponentItem;
import variabilitysmelldetection.measurement.models.Item;



public class NumberOfRefinedConstants extends Measure {

	public NumberOfRefinedConstants() {
		super("Number of Refined Constants", "NRC");
	}

	@Override
	public void measure(List<ComponentItem> items) {
	
		int numOfRefinedConstants = 0;
		for (Item item : items) {
			
			if (!item.isRefinement()) {
				
				for (Item i : items) {
					
					if (i.isRefinement() && 
							!item.getParentName().equals(i.getParentName()) && 
							item.getName().equals(i.getName())) {
						numOfRefinedConstants++;
						break;
					}
				}
			}
		}
		setValue(numOfRefinedConstants);
	}
}
